﻿using System;
using System.ComponentModel;

namespace GBlason.ViewModel.Contract
{
    /// <summary>
    /// Data structure used to store the data for all the property displayer (in the property screen)
    /// </summary>
    public class PropertyDisplayer : INotifyPropertyChanged
    {
        /// <summary>
        /// Gets or sets the name of the property (for display purpose, so it is localized).
        /// </summary>
        /// <value>
        /// The name of the property.
        /// </value>
        public String PropertyName { get; set; }

        public Object PropertyValue
        {
            get { return _propertyValue; }
            set { if (value == _propertyValue) return;
                _propertyValue = value;
                OnPropertyChanged("PropertyValue");
            }
        }

        /// <summary>
        /// The stored current value of this property
        /// </summary>
        private Object _propertyValue;

        /// <summary>
        /// Gets or sets the type of the property value.
        /// </summary>
        /// <value>
        /// The type of the property value.
        /// </value>
        public Type PropertyValueType { get; set; }

        #region INotifyPropertyChanged Members

        protected void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        public event PropertyChangedEventHandler PropertyChanged;
        #endregion
    }
}
